package cn.ainit.edi.app;

import java.io.InputStream;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import cn.ainit.byf.station.Station;
import cn.ainit.common.DzEDIType;
import cn.ainit.edi.entity.SysDBSchemaCodeList;
import cn.ainit.edi.entity.SysDBSchemaInfo;
import cn.ainit.exchange.entity.ExchangeColumn;
import cn.ainit.exchange.entity.ExchangeGroup;
import cn.ainit.exchange.entity.ExchangeTable;
import cn.ainit.exchange.entity.MappingGroup;
import cn.ainit.exchange.entity.MappingTable;
import cn.ainit.sys.query.datastore.DataStore;
import cn.ainit.sys.query.entity.QueryJson;

@Service
public class SysEDIServiceImpl implements SysEDIService{
	
	SysEDIDao sysEDIDao;
	
	@Resource
	public void setSysEDIDao(SysEDIDao sysEDIDao) {
		this.sysEDIDao = sysEDIDao;
	}
	
	/***
	 * 执行sql语句
	 */
	@Override
	public boolean executeSql(String createSql) throws Exception {
		return sysEDIDao.executeUSQL(createSql);
	}
	/***
	 * 保存schema文件
	 * @throws Exception 
	 */
	@Override
	public boolean saveSchema(SysDBSchemaInfo schemaInfo) throws Exception {
		return sysEDIDao.saveSchema(schemaInfo);
	}
	
	@Override
	public boolean saveSchemaFile(InputStream inputStream,String schemaTypeId) throws Exception {
		return sysEDIDao.saveSchemaFile(inputStream,schemaTypeId);
	}
	
	@Override
	public boolean saveSchemaColumns(List<SysDBSchemaCodeList> schemaColumns)
			throws Exception {
		return sysEDIDao.saveSchemaColumns(schemaColumns);
	}
	
	@Override
	public boolean saveExcGroup(ExchangeGroup group) throws Exception {
		return sysEDIDao.saveExcGroup(group);
	}
	
	@Override
	public boolean updateExcGroup(ExchangeGroup group) throws Exception {
		return sysEDIDao.updateExcGroup(group);
	}
	
	@Override
	public QueryJson findExcGroup(int pageSize, int pageNumber,
			String config) throws Exception {
		return sysEDIDao.findExcGroup( pageSize, pageNumber,config);
	}
	
	@Override
	public List<Station> queryStation() throws Exception {
		return sysEDIDao.queryStation();
	}
	
	@Override
	public List<DzEDIType> querySourceType() throws Exception {
		return sysEDIDao.querySourceType();
	}
	
	@Override
	public List<ExchangeGroup> queryAllExchangeG() throws Exception {
		return sysEDIDao.queryAllExchangeG();
	}
	
	@Override
	public List<ExchangeGroup> queryExchangeGById(String groupId)
			throws Exception {
		return sysEDIDao.queryExchangeGById(groupId);
	}
	
	@Override
	public List<ExchangeTable> queryExcTabByGroupId(String groupId, String isRoot)
			throws Exception {
		return sysEDIDao.queryExcTabByGroupId(groupId,isRoot);
	}
	@Override
	public boolean saveExcTable(ExchangeTable exchangeTable) throws Exception {
		return sysEDIDao.saveExcTable(exchangeTable);
	}
	@Override
	public boolean updateExcTable(ExchangeTable exchangeTable) throws Exception {
		return sysEDIDao.updateExcTable(exchangeTable);
	}
	
	@Override
	public boolean delExcTable(String groupTableId) throws Exception {
		return sysEDIDao.delExcTable(groupTableId);
	}
	
	@Override
	public List<ExchangeColumn> queryExcClnByIds(String groupId,
			String groupTableId) throws Exception {
		return sysEDIDao.queryExcClnByIds(groupId,groupTableId);
	}
	
	@Override
	public ExchangeTable loadExcTableById(String groupTableId) throws Exception {
		return sysEDIDao.loadExcTableById(groupTableId);
	}
	
	@Override
	public DataStore loadDataStoreById(String dataSelectDsid) throws Exception {
		return sysEDIDao.loadDataStoreById(dataSelectDsid);
	}
	
	@Override
	public List<String> getSqlColumns(String sqlText) throws Exception {
		return sysEDIDao.getSqlColumns(sqlText);
	}
	
	@Override
	public List<ExchangeColumn> queryExcClnFromDS(String dataSelectDsid)
			throws Exception {
		return sysEDIDao.queryExcClnFromDS(dataSelectDsid);
	}
	
	@Override
	public boolean saveExcClns(List<ExchangeColumn> excColumns) throws Exception {
		return sysEDIDao.saveExcClns(excColumns);
	}
	
	@Override
	public boolean delExcClnsByIds(String sqlTxt, String groupId,
			String groupTableId) throws Exception {
		return sysEDIDao.delExcClnsByIds(sqlTxt, groupId, groupTableId);
	}
	
	@Override
	public QueryJson queryMappingGroup(int rows, int page, String config)
			throws Exception {
		return sysEDIDao.queryMappingGroup(rows,page,config);
	}
	
	@Override
	public List queryDzSource(String sql) throws Exception {
		return sysEDIDao.queryDzSource(sql);
	}
	
	@Override
	public boolean saveMapGroup(MappingGroup mappingGroup) throws Exception {
		return sysEDIDao.saveMapGroup(mappingGroup);
	}
	
	
	@Override
	public boolean updateMapGroup(MappingGroup mappingGroup) throws Exception {
		return sysEDIDao.updateMapGroup(mappingGroup);
	}
	
	@Override
	public QueryJson queryMappingTable(int rows, int page, String mappingGroupId)
			throws Exception {
		return sysEDIDao.queryMappingTable(rows, page, mappingGroupId);
	}
	
	@Override
	public boolean saveMapTable(MappingTable mappingTable) throws Exception {
		return sysEDIDao.saveMapTable(mappingTable);
	}
	
	@Override
	public boolean updateMapTable(MappingTable mappingTable) throws Exception {
		return sysEDIDao.updateMapTable(mappingTable);
	}

	@Override
	public Map<String,List<Map<String, Object>>> xmlIm(String TYPE,String CUSTOMRANGE,String SQLTITLE,String	SQL,String SQLITME) {
		
		return sysEDIDao.xmlIm(TYPE, CUSTOMRANGE,SQLTITLE,SQL,SQLITME); 
	}

	@Override
	public void saveLog(String SUPPLY_SITE, String LOGTPYE,
			Boolean COMPLETESTATE, String MSG, String FILENAME,
			String STARTTIME, String ENDTIME, Long FILESIZE,
			String TARGETURL, String LOCALURL, String DATATPYE, String DATAID) {
		  sysEDIDao.saveLog(SUPPLY_SITE, LOGTPYE, COMPLETESTATE, MSG, FILENAME, STARTTIME, ENDTIME, FILESIZE, TARGETURL, LOCALURL, DATATPYE, DATAID);
		
	}

	@Override
	public void saveXml(Map<String, Object> sqlMap) {
		sysEDIDao.saveXml(sqlMap);
		
	}
	
}
